// view/my/guanzhu/guanzhu.js
let app = getApp()
let yuming = app.globalData.yuming
var shuzong = []
var shu = []
const request = require('../../config/request');
Page({

  /**
   * 页面的初始数据
   */
  ...request,
  data: {
    yuming: yuming,
    heights: '',
    title: "关注",
    lie: [],
    page: 1
  },
  xq(e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/page_two/bosszhuye/bosszhuye?id=' + id,
    })
  },
  // 查看更多
  lookmore() {
    shuzong = this.data.lie
    this.setData({
      page: (this.data.page) + 1
    })
    this.list()
  },
  // 关注
  quguan(e) {
    console.log(e)
    var id = e.currentTarget.dataset.id
    var that = this
    this.myRequest(yuming + 'shop/shopAddBossfollow', {
      shopId: wx.getStorageSync('shopId'),
      fid: id
    }, 'POST').then(res => {
      wx.showToast({
        title: res.data.msg,
        icon: 'none'
      })
      that.list()
    })
  },
  list() {
    var that = this
    this.myRequest(yuming + 'shop/shopByFollowList', {
      page: that.data.page,
      shopId: wx.getStorageSync('shopId'),
    }, 'POST').then(res => {
      wx.hideLoading({})
      shu = res.data.data
      if (that.data.page != 1) {
        if (shu.length == 0) {
          wx.showToast({
            title: '没有更多数据了~',
            icon: "none"
          })
          that.setData({
            lie: []
          })
        }
      }
      that.setData({
        lie: shuzong.concat(shu)
      })
    })
  },
  backs() {
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5,
      title: options.title
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.list()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})